/* Copyright 2010 Michael Wenders, michaelwenders <at> gmx <dot> de

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CONFIG_H_
#define CONFIG_H_

#include "lcmd_includes.h"

class Lcmd;

class LcmdConfig
{
    private:
	/* config filename */
	string filename;

	/* some helper vars */
	int lineNumber;

	/* pointer to lcmd main object */
	Lcmd *lcmd;

	/* core options */
	string configDir;
	string lockFile;
	string pidFile;
	bool daemonize;
	bool sendOnMD5Mismatch;

	/* mysql options */
	string mysqlServer;
	string mysqlDb;
	string mysqlUser;
	string mysqlPass;
	int mysqlPort;

	/* net options */
	int port;
	string interface;

	/* log options */
	int verbosityLevel;
	int loglevel;
	string logfile;

	int parseCoreOptions(string line);
	int parseNetOptions(string line);
	int parseLogOptions(string line);
	int parseMySqlOptions(string line);

    public:
	/* Constructor & Destructor*/
	LcmdConfig(Lcmd *lcmd, string filename);
	LcmdConfig(Lcmd *lcmd);
	~LcmdConfig();

	/* Setter and Getter */
	void setFilename(string filename);
	string getFilename();

	void setVerbosity(int verbosity);
	int getVerbosity();
	void increaseVerbosity();

	void setLogLevel(int loglevel);
	void setLogLevel(string loglevel);
	int getLogLevel();

	void setPort(int port);
	void setPort(string port);
	int getPort();
	bool checkPort(int port);

	void setInterface(string interface);
	string getInterface();

	void setConfigDir(string configDir);
	string getConfigDir();

	void setLockFile(string lockFile);
	string getLockFile();

	void setPidFile(string pidFile);
	string getPidFile();

	void setDaemonize(string daemonize);
	void setDaemonize(bool daemonize);
	bool getDaemonize();

	void setSendOnMD5Mismatch(string sendOnMD5Mismatch);
	void setSendOnMD5Mismatch(bool sendOnMD5Mismatch);
	bool getSendOnMD5Mismatch();

	void setCreateDirs(bool createDir);
	bool getCreateDirs();

	void setCheckVersion(bool checkVersion);
	bool getCheckVersion();

	void setMySqlServer(string mysqlServer);
	string getMySqlServer();

	void setMySqlDb(string mysqlDb);
	string getMySqlDb();

	void setMySqlUser(string mysqlUser);
	string getMySqlUser();

	void setMySqlPass(string mysqlPass);
	string getMySqlPass();

	void setMySqlPort(int mysqlPort);
	void setMySqlPort(string mysqlPort);
	int getMySqlPort();

	/* Other Methods */
	int loadAll();
	int loadFile();
	int setDefaults();
};

#endif /* CONFIG_H_ */
